//
//  AXFSystemMessageViewModel.m
//  AIXF
//
//  Created by Macx on 2017/7/14.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "AXFSystemMessageViewModel.h"
#import "AXFMineSever.h"
#import <YYModel.h>
@implementation AXFSystemMessageViewModel

+ (instancetype)shared
{
    static AXFSystemMessageViewModel *instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[AXFSystemMessageViewModel alloc] init];
    });
    return instance;
}


- (instancetype)init
{
    if (self = [super init])
    {
        [[AXFMineSever new] requestSystemMessageWith:^(NSArray *response) {
            
            NSLog(@"%@",response);
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                
                   self.modelArray =  [NSArray yy_modelArrayWithClass:[AXFMineSystemMessage class] json:response];
                    
                    [[NSNotificationCenter defaultCenter] postNotificationName:@"postAXFMineSystemMessage" object:nil];
    
            });
            
            
        } andFailBlock:^(NSError *error) {
            NSLog(@"%@",error);
            
        }];;

    }
    return self;
}


@end
